import Vue from 'vue'
import Router from 'vue-router'
import routes from "./routes.js";

Vue.use(Router)
let router = new Router({
  mode:'history',
  // base: '/dist',
  // 切换路由是  页面滚动位置
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;//期望滚动到哪个位置
    } else {
      return {
        x: 0,
        y: 0
      };
    }
  },
  routes
});

router.beforeEach((to, from, next) => {
  window.document.title = to.meta.name == undefined ? to.meta.name : to.meta.name
  next()
})


export default router



